﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using PAT.Entities;
using PAT.Services;
using PAT.Data.Bases;

public partial class WebForms_Login : System.Web.UI.Page
{
    /// <summary>
    /// Proveedor de servicios que permite accesar a la funcionalidad de usuarios
    /// </summary>
    private PatUsuarioService usuarioService = new PatUsuarioService();
    
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void lgnPAT_LoggedIn(object sender, EventArgs e)
    {
        PatUsuarioParameterBuilder filtro = new PatUsuarioParameterBuilder();
        filtro.AppendEquals(PatUsuarioColumn.Login, lgnPAT.UserName);
        TList<PatUsuario> usuarioPorLogin = usuarioService.Find(filtro.GetParameters());
        if (usuarioPorLogin.Count == 1)
            Session["usuario"] = usuarioPorLogin[0];
        if (Request["ReturnUrl"] == null)
            Response.Redirect("aspx/inicio/Home.aspx");
    }
}